﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace EFCore.Models;

public partial class WmssystemContext : DbContext
{
    public WmssystemContext()
    {
    }

    public WmssystemContext(DbContextOptions<WmssystemContext> options)
        : base(options)
    {
    }
    public DbSet<PO_Purchaseorders> PO_Purchaseorders { get; set; }
    public DbSet<PO_Purchasedetails> PO_Purchasedetails { get; set; }
    public DbSet<Pr_Productinformation> Pr_Productinformation { get; set; }
    public DbSet<PO_PublicAttachment> PO_PublicAttachment { get; set; }
    public DbSet<sys_inventory_details> sys_inventory_details { get; set; }
    public DbSet<sys_inventory> sys_inventory { get; set; }


    public DbSet<Su_Suppliermanagement> Su_Suppliermanagement { get; set; }
    public DbSet<Sys_OrganizationalStructure> Sys_OrganizationalStructure { get; set; }
    public DbSet<Sys_PositionManagement> Sys_PositionManagement { get; set; }
    public DbSet<Sys_Dictionary> Sys_Dictionary { get; set; }
    public DbSet<Sys_Subordinate> Sys_Subordinate { get; set; }


    public DbSet<PO_Inbound> PO_Inbound { get; set; }
    public DbSet<PO_Inventorydetails> PO_Inventorydetails { get; set; }


    public DbSet<PO_Outbound> PO_Outbound { get; set; }

    public DbSet<PO_Outbounddetails> PO_Outbounddetails { get; set; }

    public DbSet<Sys_kc_allot> Sys_kc_allot { get; set; }
    public DbSet<Sys_kc_allot_detail> Sys_kc_allot_detail { get; set; }

    public DbSet<PO_Purchasereturn> PO_Purchasereturn { get; set; }

    public DbSet<PO_Purchasereturndetail> PO_Purchasereturndetail { get; set; }

    public DbSet<Sys_warehouselocation> Sys_warehouselocation { get; set; }

    public DbSet<Sys_warehouse> Sys_warehouse { get; set; }
    public DbSet<Sys_Inventorytype> Sys_Inventorytype { get; set; }
    public DbSet<Su_Customermanagement> Su_Customermanagement { get; set; }
    public DbSet<PO_Salesorder> PO_Salesorder { get; set; }
    public DbSet<PO_Salesorderdetail> PO_Salesorderdetail { get; set; }

    public DbSet<PO_Salesreturn> PO_Salesreturn { get; set; }
    public DbSet<PO_Salesreturndetails> PO_Salesreturndetails { get; set; }


    public virtual DbSet<SysPermission> SysPermissions { get; set; }


    public virtual DbSet<SysRole> SysRoles { get; set; }
    public virtual DbSet<PO_ProductType> PO_ProductType { get; set; }

    public virtual DbSet<SysRolePermission> SysRolePermissions { get; set; }

    public virtual DbSet<SysUser> SysUser { get; set; }

    public virtual DbSet<SysUserRole> SysUserRoles { get; set; }

    public virtual DbSet<UserPermissionsView> UserPermissionsViews { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseSqlServer("Data Source=rm-cn-zv23ply3700016qo.sqlserver.rds.aliyuncs.com, 1433;Initial Catalog=WMS;User ID=wms_s123;Password=Lzb123456;Encrypt=False;");
    //Data Source=a3c781\\MSSQLSERVER2012;Initial Catalog=WMSSystem;User=sa;Password=123;Encrypt=True;TrustServerCertificate=True;

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<SysPermission>(entity =>
        {
            entity.HasKey(e => e.PPerId).HasName("PK__Permissi__4FCB0F2E273C3E8A");

            entity.ToTable("Sys_Permission");

            entity.Property(e => e.PPerId).HasColumnName("P_PerId");
            entity.Property(e => e.PParentNum)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasColumnName("P_ParentNum");
            entity.Property(e => e.PPcreateTime)
                .HasColumnType("datetime")
                .HasColumnName("P_PCreateTime");
            entity.Property(e => e.PPcreateUser).HasColumnName("P_PCreateUser");
            entity.Property(e => e.PPicon)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasColumnName("P_PIcon");
            entity.Property(e => e.PPisDelete).HasColumnName("P_PIsDelete");
            entity.Property(e => e.PPname)
                .HasMaxLength(20)
                .IsUnicode(false)
                .HasColumnName("P_PName");
            entity.Property(e => e.PPnum)
                .HasMaxLength(20)
                .IsUnicode(false)
                .HasColumnName("P_PNum");
            entity.Property(e => e.PPremark).HasColumnName("P_PRemark");
            entity.Property(e => e.PPstatus)
                .IsRequired()
                .HasDefaultValueSql("((1))")
                .HasColumnName("P_PStatus");
            entity.Property(e => e.PPupdateTime)
                .HasColumnType("datetime")
                .HasColumnName("P_PUpdateTime");
            entity.Property(e => e.PPupdateUser).HasColumnName("P_PUpdateUser");
            entity.Property(e => e.PPurl)
                .HasMaxLength(255)
                .HasColumnName("P_PUrl");
        });

        modelBuilder.Entity<SysRole>(entity =>
        {
            entity.HasKey(e => e.RRid).HasName("PK__Role__7BF79CC16FE34B47");

            entity.ToTable("Sys_Role");

            entity.Property(e => e.RRid).HasColumnName("R_RId");
            entity.Property(e => e.RRcreateTime)
                .HasColumnType("datetime")
                .HasColumnName("R_RCreateTime");
            entity.Property(e => e.RRcreateUser).HasColumnName("R_RCreateUser");
            entity.Property(e => e.RRemark).HasColumnName("R_Remark");
            entity.Property(e => e.RRisDelete).HasColumnName("R_RIsDelete");
            entity.Property(e => e.RRname)
                .HasMaxLength(20)
                .IsUnicode(false)
                .HasColumnName("R_RName");
            entity.Property(e => e.RRnumber).HasColumnName("R_RNumber");
            entity.Property(e => e.RRsort).HasColumnName("R_RSort");
            entity.Property(e => e.RRstatus)
                .IsRequired()
                .HasDefaultValueSql("((1))")
                .HasColumnName("R_RStatus");
            entity.Property(e => e.RRupdateTime)
                .HasColumnType("datetime")
                .HasColumnName("R_RUpdateTime");
            entity.Property(e => e.RRupdateUser).HasColumnName("R_RUpdateUser");
        });

        modelBuilder.Entity<SysRolePermission>(entity =>
        {
            entity.HasKey(e => e.RpId).HasName("PK__RolePerm__850C7721E6533B41");

            entity.ToTable("Sys_Role_Permission");

            entity.Property(e => e.RpId).HasColumnName("RP_ID");
            entity.Property(e => e.RpCreateTime)
                .HasColumnType("datetime")
                .HasColumnName("RP_CreateTime");
            entity.Property(e => e.RpCreatedUser).HasColumnName("RP_CreatedUser");
            entity.Property(e => e.RpPermissionId).HasColumnName("RP_PermissionID");
            entity.Property(e => e.RpRoleId).HasColumnName("RP_RoleID");
            entity.Property(e => e.RpUpdateTime)
                .HasColumnType("datetime")
                .HasColumnName("RP_UpdateTime");
            entity.Property(e => e.RpUpdatedUser).HasColumnName("RP_UpdatedUser");
        });

        modelBuilder.Entity<SysUser>(entity =>
        {
            entity.HasKey(e => e.UUid).HasName("PK__User__058630FFD6FE2866");

            entity.ToTable("Sys_User");

            entity.Property(e => e.UUid).HasColumnName("U_UId");
            entity.Property(e => e.UUcreateTime)
                .HasColumnType("datetime")
                .HasColumnName("U_UCreateTime");
            entity.Property(e => e.UUcreateUser).HasColumnName("U_UCreateUser");
            entity.Property(e => e.UUdepartmentId).HasColumnName("U_UDepartmentId");
            entity.Property(e => e.UUimg).HasColumnName("U_UImg");
            entity.Property(e => e.UUisDelete).HasColumnName("U_UIsDelete");
            entity.Property(e => e.UUpdateTime)
                .HasColumnType("datetime")
                .HasColumnName("U_UpdateTime");
            entity.Property(e => e.UUpdateUser).HasColumnName("U_UpdateUser");
            entity.Property(e => e.UUphone)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasColumnName("U_UPhone");
            entity.Property(e => e.UUpostId).HasColumnName("U_UPostId");
            entity.Property(e => e.UUpwd)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasColumnName("U_UPwd");
            entity.Property(e => e.UUremark).HasColumnName("U_URemark");
            entity.Property(e => e.UUroleId).HasColumnName("U_URoleId");
            entity.Property(e => e.UUserAccount)
                .HasMaxLength(50)
                .HasColumnName("U_UserAccount");
            entity.Property(e => e.UUserName)
                .HasMaxLength(20)
                .IsUnicode(false)
                .HasColumnName("U_UserName");
            entity.Property(e => e.UUsex).HasColumnName("U_USex");
            entity.Property(e => e.UUsort).HasColumnName("U_USort");
            entity.Property(e => e.UUstatus)
                .IsRequired()
                .HasDefaultValueSql("((1))")
                .HasColumnName("U_UStatus");
        });

        modelBuilder.Entity<SysUserRole>(entity =>
        {
            entity.HasKey(e => e.UrId).HasName("PK__UserRole__C6073B2A8DCB406B");

            entity.ToTable("Sys_User_Role");

            entity.Property(e => e.UrId).HasColumnName("UR_ID");
            entity.Property(e => e.UrCreateTime)
                .HasColumnType("datetime")
                .HasColumnName("UR_CreateTime");
            entity.Property(e => e.UrCreatedUser).HasColumnName("UR_CreatedUser");
            entity.Property(e => e.UrRoleId).HasColumnName("UR_RoleID");
            entity.Property(e => e.UrUpdateTime)
                .HasColumnType("datetime")
                .HasColumnName("UR_UpdateTime");
            entity.Property(e => e.UrUpdatedUser).HasColumnName("UR_UpdatedUser");
            entity.Property(e => e.UrUserId).HasColumnName("UR_UserID");
        });

        modelBuilder.Entity<UserPermissionsView>(entity =>
        {
            entity
                .HasNoKey()
                .ToView("user_permissions_view");

            entity.Property(e => e.PParentNum)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasColumnName("P_ParentNum");
            entity.Property(e => e.PPicon)
                .HasMaxLength(50)
                .IsUnicode(false)
                .HasColumnName("P_PIcon");
            entity.Property(e => e.PPisDelete).HasColumnName("P_PIsDelete");
            entity.Property(e => e.PPname)
                .HasMaxLength(20)
                .IsUnicode(false)
                .HasColumnName("P_PName");
            entity.Property(e => e.PPnum)
                .HasMaxLength(20)
                .IsUnicode(false)
                .HasColumnName("P_PNum");
            entity.Property(e => e.PPurl)
                .HasMaxLength(255)
                .HasColumnName("P_PUrl");
            entity.Property(e => e.UUid).HasColumnName("U_UId");
            entity.Property(e => e.UUimg).HasColumnName("U_UImg");
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
